using System;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;

public class AutoMove : TriggerItem
{
    public float Delay;
    public Vector3 EndPoint;

    private Sequence seq;
    
    // Start is called before the first frame update
    void Start()
    {
        if (!StartOnAwake)
            return;

        Play();
    }

    public override void Play()
    {
        seq = DOTween.Sequence();
        seq.AppendInterval(Delay);
        seq.Append(transform.DOLocalMove(EndPoint, Duration));
        seq.AppendInterval(Delay);
        if (isLoop)
            seq.SetLoops(-1, LoopType.Yoyo);
        
    }

    void OnDestroy()
    {
        transform.DOKill();
    }

}
